package m1;

import m1.RPC.RPC;
import m1.client.Client;
import m1.server.Server;
import m2.links.Attachment;
import m2.other.Config;

public class System extends Config{

	private Client client = Client.getInstance();
	private RPC rpc = RPC.getInstance();
	private Server server = Server.getInstance();
	private Attachment receiveCalleeClientRPC;
	private Attachment sendCallerClientRPC;
	private Attachment receiveCalleeServerRPC;
	private Attachment sendCallerServerRPC;
	
	public System(){
		
		//Client - rpc
		receiveCalleeClientRPC = new Attachment();
		receiveCalleeClientRPC.connectRoleToPort(rpc.getProvidedRole("CalleeClientRPC"), client.getRequiredPort("ReceiveRequest"));
			
		sendCallerClientRPC = new Attachment();
		sendCallerClientRPC.connectPortToRole(client.getProvidedPort("SendRequest"), rpc.getRequiredRole("CallerClientRPC"));
				
		//Rpc - server
		receiveCalleeServerRPC = new Attachment();
		receiveCalleeServerRPC.connectRoleToPort(rpc.getProvidedRole("CalleeServerRPC"), server.getRequiredPort("ReceiveRequestServer"));

		sendCallerServerRPC = new Attachment();
		sendCallerServerRPC.connectPortToRole(server.getProvidedPort("SendRequestServer"), rpc.getRequiredRole("CallerServerRPC"));
	
	}
	
	/**
	 * 
	 * @return
	 */
	public Client getClient(){
		return client;
	}
	
	/**
	 * 
	 * @return
	 */
	public Server getServer(){
		return server;
	}
	
}
